package net.heartbeat.handler;

/**
 * 任务类：检查收到的心跳，以确定掉线和上线的对象
 * 
 * @author Bai Yu
 *
 */
public class CheckHeartbeat implements Runnable {
	public CheckHeartbeat(HeartbeatAbsenceDetecter abscenceDetecter, AbsenceListener absenceListener) {
		this.abscenceDetecter = abscenceDetecter;
		this.absenceListener = absenceListener;
	}

	@Override
	public void run() {
		abscenceDetecter.checkPoint();

		if (absenceListener != null) {
			absenceListener.onAbsent(abscenceDetecter.getRecentlyAbsent());
		}
	}

	private HeartbeatAbsenceDetecter abscenceDetecter;
	private AbsenceListener absenceListener;
}
